package main

import (
	"fmt"
	"reflect"
)

//变量 、interface{} reflect.Value的相互转换
func main() {
	stu := test(Student{
		Name: "路飞",
		Age:  10,
	})
	fmt.Printf("%v", stu)
}

func test(val interface{}) Student {
	//将interface{}转换为reflect.Value

	rVal := reflect.ValueOf(val)

	//将reflect.Value转换为interface{}

	iVal := rVal.Interface()

	//将interface{}转换为Student

	stu := iVal.(Student)

	return stu

}

type Student struct {
	Name string
	Age  uint8
}
